import requests
import json

# API的URL
api_url = "http://localhost/v1/chat-messages"

# API密钥
api_key = "app-v4h9uAAZJ91dwUAgDxFUcYI9"

# 请求数据
data = {
    "inputs": {},
    "query": "请推荐一下等一下吃什么",
    "response_mode": "blocking",
    "conversation_id": "",
    "user": "zhx"
}

# 请求头
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

print("headers:", headers)
print("data:", data)

# 发送POST请求
response = requests.post(api_url, headers=headers, data=json.dumps(data))

# 检查响应状态码
if response.status_code == 200:
    print("Request successful")
    print("Response:", response.json())
else:
    print(f"Request failed with status code: {response.status_code}")
    print("Error:", response.text)